If we don't do the move-selected-item below pointer thingie, do the
authorMatthias Clasen <mclasen@redhat.com>
Mon, 10 May 2004 18:17:47 +0000 (18:17 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 10 May 2004 18:17:47 +0000 (18:17 +0000)
2004-05-10  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
do the move-selected-item below pointer thingie, do the
place-below-or-above one.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcombobox.c

index 76f24eeba9f8d84e82422f5488addaf1ea3d1a7f..d5cbf40fc601a44b3f0745f741f83105ad752f3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-05-10  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
+       do the move-selected-item below pointer thingie, do the 
+       place-below-or-above one.
+
        * tests/testentrycompletion.c: Make the second example use the 
        ::match-selected signal to make it actually work.
 
index 76f24eeba9f8d84e82422f5488addaf1ea3d1a7f..d5cbf40fc601a44b3f0745f741f83105ad752f3d 100644 (file)
@@ -1,5 +1,9 @@
 2004-05-10  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
+       do the move-selected-item below pointer thingie, do the 
+       place-below-or-above one.
+
        * tests/testentrycompletion.c: Make the second example use the 
        ::match-selected signal to make it actually work.
 
index 76f24eeba9f8d84e82422f5488addaf1ea3d1a7f..d5cbf40fc601a44b3f0745f741f83105ad752f3d 100644 (file)
@@ -1,5 +1,9 @@
 2004-05-10  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
+       do the move-selected-item below pointer thingie, do the 
+       place-below-or-above one.
+
        * tests/testentrycompletion.c: Make the second example use the 
        ::match-selected signal to make it actually work.
 
index 76f24eeba9f8d84e82422f5488addaf1ea3d1a7f..d5cbf40fc601a44b3f0745f741f83105ad752f3d 100644 (file)
@@ -1,5 +1,9 @@
 2004-05-10  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
+       do the move-selected-item below pointer thingie, do the 
+       place-below-or-above one.
+
        * tests/testentrycompletion.c: Make the second example use the 
        ::match-selected signal to make it actually work.
 
index 118267e0bd657043fd32dc0735c7f3987afd794a..fdb1c675353500557fc3859e0d6292b54f0db146 100644 (file)
@@ -948,30 +948,48 @@ gtk_combo_box_menu_position_below (GtkMenu  *menu,
                                   gint     *push_in,
                                   gpointer  user_data)
 {
+  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
   gint sx, sy;
   GtkWidget *child;
   GtkRequisition req;
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+  GdkScreen *screen;
+  gint monitor_num;
+  GdkRectangle monitor;
   
   /* FIXME: is using the size request here broken? */
    child = GTK_BIN (combo_box)->child;
    
    gdk_window_get_origin (child->window, &sx, &sy);
    
+   if (GTK_WIDGET_NO_WINDOW (child))
+      {
+       sx += child->allocation.x;
+       sy += child->allocation.y;
+      }
+
    gtk_widget_size_request (GTK_WIDGET (menu), &req);
-   
+
    if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
      *x = sx;
    else
      *x = sx + child->allocation.width - req.width;
-   *y = sy + child->allocation.height;
-   
-   if (GTK_WIDGET_NO_WINDOW (child))
-      {
-       *x += child->allocation.x;
-       *y += child->allocation.y;
-      }
-   
+   *y = sy;
+
+  screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
+  monitor_num = gdk_screen_get_monitor_at_window (screen, 
+                                                 GTK_WIDGET (combo_box)->window);
+  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+  
+  if (*x < monitor.x)
+    *x = monitor.x;
+  else if (*x + req.width > monitor.x + monitor.width)
+    *x = monitor.x + monitor.width - req.width;
+  
+  if (*y + child->allocation.height + req.height <= monitor.y + monitor.height)
+    *y += child->allocation.height;
+  else
+    *y -= req.height;
+
    *push_in = TRUE;
 }